﻿<UserControl x:Class="FIFP.DashBoard.Views.OptManagement"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"  
    xmlns:local="clr-namespace:FIFP.DashBoard.Views"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    DataContext="{Binding OptMngVM,Source={StaticResource ServiceLocator}}"            
    mc:Ignorable="d"
    d:DesignHeight="1028" d:DesignWidth="1920">

    <Grid x:Name="LayoutRoot" Background="{StaticResource MainBackground}" Margin="0,5,0,0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <StackPanel Orientation="Vertical" Margin="0,0,15,0">
            <Border BorderThickness="0" Margin="1,1,1,0" Background="{StaticResource FilterBackground}">
                <TextBlock TextWrapping="Wrap" Text="Unit Type" Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="5,0"/>
            </Border>

            <ListBox Margin="2,5,0,0"  ItemsSource="{Binding UnitTypeList}" Background="#FF303440" Foreground="Gray" BorderBrush="{x:Null}"  >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <RadioButton Name="radioUnitType" ClickMode="Press" Tag="{Binding }" Content="{Binding }"
                                     Command="{Binding Source={StaticResource ServiceLocator},Path=OptMngVM.CheckedUnitTypeEvent}" CommandParameter="{Binding ElementName=radioUnitType}"
                                     Foreground="Gray" FontSize="11"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <!--<TextBlock TextWrapping="Wrap" Text="Start Date" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,4"/>
            <sdk:DatePicker Style="{StaticResource DatePickerStyle}" Margin="0,0,0,10" d:LayoutOverrides="Height" />
            <TextBlock TextWrapping="Wrap" Text="End Date" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,4"/>
            <sdk:DatePicker Style="{StaticResource DatePickerStyle}" Margin="0,0,0,4" d:LayoutOverrides="Height"/>-->
        </StackPanel>


        <Grid Grid.Column="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="AUTO"/>
                <RowDefinition Height="AUTO"/>
                <RowDefinition Height="AUTO"/>
            </Grid.RowDefinitions>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <StackPanel x:Name="opportunityPanel"  Orientation="Vertical" Grid.Column="0" Margin="0,0,20,0" >
                    <TextBlock Text="Locations with Opportunities" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,8"/>
                    <sdk:DataGrid x:Name="opportunityGrid" ItemsSource="{Binding OptimizationOpportunities}" AutoGenerateColumns="False" 
                           Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Loaded">
                                <i:InvokeCommandAction Command="{Binding OpportunityGroupLoadCommand}" 
        							CommandParameter="{Binding ElementName=opportunityGrid}" />
                            </i:EventTrigger>

                            <i:EventTrigger EventName="SelectionChanged">
                                <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=OptMngVM.OpportunitySelectChange}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Header="Unit Type" Binding="{Binding UnitType, Mode=OneWay}"  Width="90"/>
                            <sdk:DataGridTextColumn Header="Unit Name" Binding="{Binding UnitName, Mode=OneWay}"  />
                        </sdk:DataGrid.Columns>
                    </sdk:DataGrid>
                </StackPanel>

                <StackPanel x:Name="relatedPlansPanel" Orientation="Vertical" Grid.Column="1" Margin="0,0,20,0">

                    <TextBlock Text="Related Plans" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,8"/>                       

                    <sdk:DataGrid x:Name="relatedPlansGrid" ItemsSource="{Binding SelectedAppointments}" AutoGenerateColumns="False" 
                           Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}">
                        <sdk:DataGrid.Columns>
                            <sdk:DataGridTextColumn Header="Activity"   Binding="{Binding ActivityType, Mode=OneWay}"  Width="90"/>
                            <sdk:DataGridTextColumn Header="Unit Name"  Binding="{Binding UnitName, Mode=OneWay}"  Width="90"/>
                            <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding OriginalStart, Mode=OneWay, StringFormat=yyyy-MM-dd}"  Width="90"/>
                            <sdk:DataGridTextColumn Header="End Date"   Binding="{Binding OriginalEnd,   Mode=OneWay, StringFormat=yyyy-MM-dd}"  Width="90"/>
                        </sdk:DataGrid.Columns>

                    </sdk:DataGrid>

                </StackPanel>

                <StackPanel x:Name="planReschedulePanel" Orientation="Vertical" Grid.Column="2">
                    <TextBlock Text="Plan Rescheduled" Style="{StaticResource SmallHeading}" VerticalAlignment="Top" Margin="0,0,0,8"/>

                    <sdk:DataGrid x:Name="planRescheduledGrid" ItemsSource="{Binding SelectedAppointments}" AutoGenerateColumns="False" 
                           Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}" IsReadOnly="False">
                        <sdk:DataGrid.Columns>
                            <!--<sdk:DataGridTemplateColumn Header="Modified Start Date" Width="160">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:DatePicker SelectedDate="{Binding Start, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=Default}"  Style="{StaticResource DatePickerStyle}" />
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>

                            <sdk:DataGridTemplateColumn Header="Modified End Date" Width="160">
                                <sdk:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <sdk:DatePicker SelectedDate="{Binding End, Mode=TwoWay, NotifyOnValidationError=True, UpdateSourceTrigger=Default}"  Style="{StaticResource DatePickerStyle}" />
                                    </DataTemplate>
                                </sdk:DataGridTemplateColumn.CellTemplate>
                            </sdk:DataGridTemplateColumn>-->

                        <sdk:DataGridTextColumn Header="Modified Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=yyyy-MM-dd}" Width="160"/>
                        <sdk:DataGridTextColumn Header="Modified End Date"   Binding="{Binding End, Mode=OneWay, StringFormat=yyyy-MM-dd}" Width="160" />
                        

                        </sdk:DataGrid.Columns>

                    </sdk:DataGrid>

                </StackPanel>

            </Grid>

            <Path Data="M25.666672,37 L204.34454,37" Margin="0,20,0,0" Grid.Row="1" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="False" VerticalAlignment="Top" Height="1" Stroke="{StaticResource LineColor}"/>

            <Grid Margin="0,10,0,0" Grid.Row="2" >
                <local:UCAppointment_New x:Name="optimizedAppointment" />
            </Grid>
            

        </Grid>
    </Grid>
</UserControl>
